﻿

using System;
using System.Threading.Tasks;

using Xc.DataAccess.AepCoapCore.Models;
using Xc.DataAccess.Core;

namespace Lzkj.AepCoapCore
{
    public interface IAepCoapService
    {
        string BatchCreateNBDevice(string appKey, string appSecret, string body, string MasterKey);

        /// <summary>
        /// 绑定设备
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string BindDevice<TBody>(BodyDevcie<TBody> createDevcie);

        /// <summary>
        /// 取消指令
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string CancelCommand(string appKey, string appSecret, string MasterKey, string body);

        /// <summary>
        /// 主任务执行控制(启动主任务开始升级)
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string ControlRemoteUpgradeTask(string appKey, string appSecret, string id, string body, string MasterKey = "");

        /// <summary>
        /// 主任务执行控制(启动主任务开始升级)
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string ControlSoftwareUpgradeTask(string appKey, string appSecret, string id, string MasterKey, string body);

        /// <summary>
        /// 不使用profile的创建指令
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string CreateCommand<Tbody>(MasterKeyInfo<Tbody> masterKeyInfo);

        /// <summary>
        /// 使用profile的下发指令
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string CreateCommandLwm2mProfile<Tbody>(MasterKeyInfo<Tbody> masterKeyInfo);

        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        Task<ResultData<AddDeviceRespond>> CreateDeviceAsync<TBody>(BodyDevcie<TBody> createDevcie);

        /// <summary>
        /// 新增分组
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string CreateDeviceGroup(string appKey, string appSecret, string body, string MasterKey = "");

        /// <summary>
        /// 创建产品
        /// </summary>
        /// <returns></returns>
        string CreateProduct<TBody>(AepInfoBasicBody<TBody> aepProduct);

        /// <summary>
        /// 创建远程升级主任务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string CreateRemoteUpgradeTask(string appKey, string appSecret, string body, string MasterKey = "");

        /// <summary>
        /// 创建远程软件升级主任务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string CreateSoftwareUpgradeTask(string appKey, string appSecret, string MasterKey, string body);

        /// <summary>
        /// 添加订阅
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// 
        ///body {
        /// 
        /// <returns></returns>
        string CreateSubscription(string appKey, string appSecret, string MasterKey, string body);

        /// <summary>
        /// 删除设备
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="productId"></param>
        /// <param name="deviceIds"></param>
        /// <returns></returns>
        string DeleteDevice(DeleteDevice deleteDevice);

        /// <summary>
        /// 删除分组
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="deviceGroupId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string DeleteDeviceGroup(string appKey, string appSecret, string productId, string deviceGroupId, string MasterKey = "");

        /// <summary>
        /// 删除固件
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="updateBy"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string DeleteFirmware(string appKey, string appSecret, string id, string productId, string updateBy = "", string MasterKey = "");

        /// <summary>
        /// 删除产品
        /// </summary>
        /// <returns></returns>
        string DeleteProduct(DeleteProduct deleteProduct);

        /// <summary>
        /// 删除远程升级主任务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="updateBy"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string DeleteRemoteUpgradeTask(string appKey, string appSecret, string id, string productId, string updateBy = "", string MasterKey = "");

        /// <summary>
        /// 删除软件升级主任务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <param name="updateBy"></param>
        /// <returns></returns>
        string DeleteSoftwareUpgradeTask(string appKey, string appSecret, string id, string productId, string MasterKey, string updateBy = "");

        /// <summary>
        /// 删除订阅
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="subId">订阅ID</param>
        /// <param name="productId"></param>
        /// <param name="subLevel">订阅级别,必填(1:产品级 2：设备级)</param>
        /// <param name="MasterKey"></param>
        /// <param name="deviceId">设备id(产品级可以不填,设备级必填),</param>
        /// <returns></returns>
        string DeleteSubscription(string appKey, string appSecret, string subId, string productId, string subLevel, string MasterKey, string deviceId = "");

        /// <summary>
        /// 设备状态历史数据分页查询  获取历史数据
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string GetDeviceStatusHisInPage(string appKey, string appSecret, string body);

        /// <summary>
        /// 数据总数获取
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string GetDeviceStatusHisInTotal(string appKey, string appSecret, string body);

        /// <summary>
        /// 查询单个订阅
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="subId"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string GetSubscription(string appKey, string appSecret, string subId, string productId, string MasterKey);

        /// <summary>
        /// 获取订阅列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="MasterKey"></param>
        /// <param name="subType"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        string GetSubscriptionsList(string appKey, string appSecret, string productId, string pageNow, string pageSize, string MasterKey, string subType = "", string searchValue = "");

        /// <summary>
        /// 修改远程升级主任务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string ModifyRemoteUpgradeTask(string appKey, string appSecret, string id, string body, string MasterKey = "");

        /// <summary>
        /// 修改软件升级主任务信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string ModifySoftwareUpgradeTask(string appKey, string appSecret, string id, string MasterKey, string body);

        /// <summary>
        /// 操作远程升级主任务（包括设备升级，取消升级，重试升级）
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string OperationalRemoteUpgradeTask(string appKey, string appSecret, string body, string MasterKey = "");

        /// <summary>
        /// 主任务执行控制(启动主任务开始升级)
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string OperationalSoftwareUpgradeTask(string appKey, string appSecret, string MasterKey, string body);

        /// <summary>
        /// 查询单条指令
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="commandId"></param>
        /// <param name="productId"></param>
        /// <param name="deviceId"></param>
        /// <returns></returns>
        string QueryCommand(string appKey, string appSecret, string MasterKey, string commandId, string productId, string deviceId = "");

        /// <summary>
        /// 获取设备指令列表
        /// </summary>
        /// <returns></returns>
        string QueryCommandList(QueryCommandList queryCommandList);

        /// <summary>
        /// 获取单个设备详情
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="deviceId"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        string QueryDevice(QueryDevice queryDevice);

        /// <summary>
        /// 查询分组列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="searchValue"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryDeviceGroupList(string appKey, string appSecret, string productId, string pageNow, string pageSize, string searchValue = "", string MasterKey = "");

        /// <summary>
        /// 产品设备列表信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="productId"></param>
        /// <param name="searchValue"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<ResultData<GetDeviceListModel>> QueryDeviceList(QueryDeviceList queryDeviceList);

        /// <summary>
        /// 终端单个最新状态查询接口
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string QueryDeviceStatus(string appKey, string appSecret, string body);

        /// <summary>
        /// 批量获取设备最新状态数据
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string QueryDeviceStatusList(string appKey, string appSecret, string body);

        /// <summary>
        /// 查询固件
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryFirmware(string appKey, string appSecret, string id, string productId, string MasterKey = "");

        /// <summary>
        /// 查询固件列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="searchValue"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryFirmwareList(string appKey, string appSecret, string productId, string searchValue = "", string pageNow = "", string pageSize = "", string MasterKey = "");

        /// <summary>
        /// 查询产品
        /// </summary>
        /// <returns></returns>
        string QueryProduct(QueryProduct queryProduct);

        /// <summary>
        /// 根据IMEI号查询信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="imei"></param>
        /// <returns></returns>
        string QueryProductInfoByImei(ImeiInfo imeiInfo);

        /// <summary>
        /// 查询产品列表
        /// </summary>
        /// <returns></returns>
        string QueryProductList(QueryProductList queryProduct);

        /// <summary>
        /// 查属性
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="productId"></param>
        /// <param name="searchValue"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        string QueryPropertyList(string appKey, string appSecret, string MasterKey, string productId, string searchValue = "", string pageNow = "", string pageSize = "");

        /// <summary>
        /// 根据公共产品ID查询公共产品信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string QueryPublicByProductId(string appKey, string appSecret, string body);

        /// <summary>
        /// 根据私有产品ID查询公共产品信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string QueryPublicByPublicProductId(string appKey, string appSecret, string body);

        /// <summary>
        /// 查询主任务详情统计
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryRemoteUpgradeDetail(string appKey, string appSecret, string id, string productId, string MasterKey = "");

        /// <summary>
        /// 查询任务详情子任务列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="taskStatus">很多种，见文档</param>
        /// <param name="searchValue">查询值，设备ID或设备编号(IMEI)或设备名称模糊查询</param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryRemoteUpgradeSubtasks(string appKey, string appSecret, string id, string productId, string taskStatus = "", string searchValue = "", string pageNow = "", string pageSize = "", string MasterKey = "");

        /// <summary>
        /// 查询任务详情基本信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id">主任务id</param>
        /// <param name="productId">产品id</param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QueryRemoteUpgradeTask(string appKey, string appSecret, string id, string productId, string MasterKey = "");

        /// <summary>
        /// 查询升级主任务列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="MasterKey"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        string QueryRemoteUpgradeTaskList(string appKey, string appSecret, string productId, string pageNow = "", string pageSize = "", string MasterKey = "", string searchValue = "");

        /// <summary>
        /// 查询可升级设备列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="isSelectDevice">查询类型（1.查询加入升级设备，2.查询可加入升级设备）</param>
        /// <param name="id">主任务id,isSelectDevice为1时必填，为2不必填</param>
        /// <param name="pageNow">当前页，默认1</param>
        /// <param name="pageSize">每页显示数，默认20</param>
        /// <param name="MasterKey"></param>
        /// <param name="deviceIdSearch">根据设备id精确查询</param>
        /// <param name="deviceNameSearch">根据设备名称精确查询</param>
        /// <param name="imeiSearch">根据imei号精确查询，仅支持LWM2M协议</param>
        /// <param name="deviceNoSearch">根据设备编号精确查询，仅支持T_Link协议</param>
        /// <param name="deviceGroupIdSearch">根据群组id精确查询</param>
        /// <returns></returns>
        string QueryRemoteUpradeDeviceList(string appKey, string appSecret, string productId, string isSelectDevice, string id = "", string pageNow = "", string pageSize = "", string MasterKey = "", string deviceIdSearch = "", string deviceNameSearch = "", string imeiSearch = "", string deviceNoSearch = "", string deviceGroupIdSearch = "");

        /// <summary>
        /// 查定义的服务
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="productId"></param>
        /// <param name="searchValue"></param>
        /// <param name="serviceType"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        string QueryServiceList(string appKey, string appSecret, string MasterKey, string productId, string searchValue = "", string serviceType = "", string pageNow = "", string pageSize = "");

        /// <summary>
        /// 查询主任务详情统计
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QuerySoftwareUpgradeDetail(string appKey, string appSecret, string id, string productId, string MasterKey);

        /// <summary>
        /// 查询软件升级详情子任务列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <param name="taskStatus"></param>
        /// <param name="searchValue"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        string QuerySoftwareUpgradeSubtasks(string appKey, string appSecret, string id, string productId, string MasterKey, string taskStatus = "", string searchValue = "", string pageNow = "", string pageSize = "");

        /// <summary>
        /// 查询任务详情基本信息
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string QuerySoftwareUpgradeTask(string appKey, string appSecret, string id, string productId, string MasterKey);

        /// <summary>
        /// 查询升级主任务列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="MasterKey"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        string QuerySoftwareUpgradeTaskList(string appKey, string appSecret, string productId, string MasterKey, string pageNow = "", string pageSize = "", string searchValue = "");

        /// <summary>
        /// 查询可升级设备列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="productId"></param>
        /// <param name="isSelectDevice"></param>
        /// <param name="MasterKey"></param>
        /// <param name="id"></param>
        /// <param name="pageNow"></param>
        /// <param name="pageSize"></param>
        /// <param name="deviceIdSearch"></param>
        /// <param name="deviceNameSearch"></param>
        /// <param name="imeiSearch"></param>
        /// <param name="deviceGroupIdSearch"></param>
        /// <returns></returns>
        string QuerySoftwareUpradeDeviceList(string appKey, string appSecret, string productId, string isSelectDevice, string MasterKey, string id = "", string pageNow = "", string pageSize = "", string deviceIdSearch = "", string deviceNameSearch = "", string imeiSearch = "", string deviceGroupIdSearch = "");

        /// <summary>
        /// 标准物模型查询
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="thirdType">三级分类id</param>
        /// <param name="standardVersion">标准物模型版本号</param>
        /// <returns></returns>
        string QueryStandardModel(string appKey, string appSecret, string thirdType, string standardVersion = "");

        /// <summary>
        /// 解除绑定
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        string UnbindDevice<TBody>(BodyDevcie<TBody> createDevcie);

        /// <summary>
        /// 更新设备
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="MasterKey"></param>
        /// <param name="deviceId"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        Task<ResultData<UpdateDeviceRespon>> UpdateDevice<TBody>(UpdateDevcie<TBody> updateDevcie);

        /// <summary>
        /// 更新分组
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string UpdateDeviceGroup(string appKey, string appSecret, string body, string MasterKey = "");

        /// <summary>
        /// 编辑分组与设备关联关系
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>
        /// <returns></returns>
        string UpdateDeviceGroupRelation(string appKey, string appSecret, string body, string MasterKey = "");

        /// <summary>
        /// 更新固件
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="appSecret"></param>
        /// <param name="id">固件</param>
        /// <param name="body"></param>
        /// <param name="MasterKey"></param>id
        /// <returns></returns>
        string UpdateFirmware(string appKey, string appSecret, string id, string body, string MasterKey = "");

        /// <summary>
        /// 更新产品
        /// </summary>
        /// <returns></returns>
        string UpdateProduct<TBody>(AepInfoBasicBody<TBody> aepProduct);
    }
}
